import { FormRule, Image, PrimaryTableCol } from 'tdesign-vue-next';

/**
 * 搜索表单项
 */
export const getSearchParams = () => [
  {
    label: '轮播标题',
    key: 'title',
    hide: false,
  },
];

/**
 * 表格列
 */
export const getColumns = (): PrimaryTableCol[] => [
  {
    title: '轮播标题',
    ellipsis: true,
    align: 'center',
    colKey: 'title',
  },
  {
    title: '图片',
    align: 'center',
    colKey: 'image',
    cell: (h, { row }) =>
      h(Image, { src: row.image, fit: 'contain', style: 'width: 150px; height: 100px;margin: 0 auto' }),
  },
  {
    title: '跳转路径',
    ellipsis: true,
    align: 'center',
    colKey: 'link',
  },
];

/**
 * 表单校验规则
 */
export const getRules = (): Record<string, FormRule[]> => ({
  title: [{ required: true, message: '请输入文章标题', type: 'error', trigger: 'blur' }],
});
